home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 684 / 684.xpi / chrome / fireftp.jar / content / js / etc / preferences.js < prev    next >
Text File  |  2008-06-14  |  6KB  |  142 lines

  1. function readPreferences(startup) {
  2.   try {
  3.     gDefaultAccount          = gPrefs.getComplexValue("defaultaccount", Components.interfaces.nsISupportsString).data;
  4.     gBytesMode               = gPrefs.getBoolPref("bytesmode");
  5.     gConcurrent              = gPrefs.getIntPref ("concurrent");
  6.     gDebugMode               = gPrefs.getBoolPref("debugmode");
  7.     gDisableDestructMode     = gPrefs.getBoolPref("destructmode");
  8.     gDonated                 = gPrefs.getBoolPref("donated");
  9.     gErrorMode               = gPrefs.getBoolPref("errormode");
  10.     gInterfaceMode           = gPrefs.getIntPref ("interfacemode");
  11.     gLogErrorMode            = gPrefs.getBoolPref("logerrormode");
  12.     gLogMode                 = gPrefs.getBoolPref("logmode");
  13.     gLogQueueMode            = gPrefs.getIntPref ("logqueue");
  14.     gNoPromptMode            = gPrefs.getBoolPref("nopromptmode");
  15.     gPasswordMode            = gPrefs.getBoolPref("passwordmode");
  16.     gRefreshMode             = gPrefs.getBoolPref("refreshmode");
  17.     gTempPasvMode            = gPrefs.getBoolPref("temppasvmode");
  18.     gWelcomeMode             = gPrefs.getBoolPref("welcomemode");
  19.     gOpenMode                = gPrefs.getIntPref ("openmode");
  20.  
  21.     gFireFTPUtils.hiddenMode = gPrefs.getBoolPref("hiddenmode");
  22.  
  23.     for (var x = 0; x < gMaxCon; ++x) {
  24.       gConnections[x].fileMode            = gPrefs.getIntPref ("filemode");    // NOTE: if you add a preference here, don't forget to update fxp.js if needed
  25.       gConnections[x].hiddenMode          = gPrefs.getBoolPref("hiddenmode");
  26.       gConnections[x].keepAliveMode       = gPrefs.getBoolPref("keepalivemode");
  27.       gConnections[x].networkTimeout      = gPrefs.getIntPref ("network");
  28.       gConnections[x].proxyHost           = gPrefs.getComplexValue("proxyhost", Components.interfaces.nsISupportsString).data;
  29.       gConnections[x].proxyPort           = gPrefs.getIntPref ("proxyport");
  30.       gConnections[x].proxyType           = gPrefs.getCharPref("proxytype");
  31.       gConnections[x].activePortMode      = gPrefs.getBoolPref("activeportmode");
  32.       gConnections[x].activeLow           = gPrefs.getIntPref ("activelow");
  33.       gConnections[x].activeHigh          = gPrefs.getIntPref ("activehigh");
  34.       gConnections[x].reconnectAttempts   = gPrefs.getIntPref ("attempts");
  35.       gConnections[x].reconnectInterval   = gPrefs.getIntPref ("retry");
  36.       gConnections[x].reconnectMode       = gPrefs.getBoolPref("timeoutmode");
  37.       gConnections[x].sessionsMode        = gPrefs.getBoolPref("sessionsmode");
  38.       gConnections[x].timestampsMode      = gPrefs.getBoolPref("timestampsmode");
  39.       gConnections[x].useCompression      = gPrefs.getBoolPref("compressmode");
  40.       gConnections[x].integrityMode       = gPrefs.getBoolPref("integritymode");
  41.     }
  42.  
  43.     if (gPrefs.getComplexValue("folder", Components.interfaces.nsISupportsString).data == "") {
  44.       var file = Components.classes["@mozilla.org/file/directory_service;1"].createInstance(Components.interfaces.nsIProperties)
  45.                            .get("Home", Components.interfaces.nsILocalFile);
  46.  
  47.       var sString  = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
  48.       if (file.path.indexOf('/') != -1) {
  49.         sString.data = file.path.substring(0, file.path.indexOf('/') + 1);
  50.       } else if (file.path.indexOf('\\') != -1) {
  51.         sString.data = file.path.substring(0, file.path.indexOf('\\') + 1);
  52.       }
  53.       gPrefs.setComplexValue("folder", Components.interfaces.nsISupportsString, sString);
  54.     }
  55.  
  56.     if (startup) {
  57.       gLocalPath.value = gPrefs.getComplexValue("folder", Components.interfaces.nsISupportsString).data;
  58.       gLoadUrl         = gPrefs.getComplexValue("loadurl", Components.interfaces.nsISupportsString).data;
  59.     }
  60.  
  61.     updateInterface();
  62.     updateOpenMode();
  63.  
  64.     $('logqueue').collapsed = !gLogMode;
  65.     $('logsplitter').state  =  gLogMode ? 'open' : 'collapsed';
  66.     $('logbutton').checked  =  gLogMode;
  67.  
  68.     $('logQueueTabs').selectedIndex = gLogQueueMode;
  69.  
  70.     $('statustype').label  = gTransferTypes[gFtp.fileMode];
  71.  
  72.     var asciiList = gPrefs.getComplexValue("asciifiles", Components.interfaces.nsISupportsString).data;
  73.     asciiList     = asciiList.split(",");
  74.     for (var x = 0; x < gMaxCon; ++x) {
  75.       for (var y = 0; y < asciiList.length; ++y) {
  76.         gConnections[x].asciiFiles.push(asciiList[y]);
  77.       }
  78.     }
  79.  
  80.   } catch (ex) {
  81.     debug(ex);
  82.   }
  83. }
  84.  
  85. function showPreferences() {
  86.   var branch       = gPrefsService.getBranch("browser.");
  87.   var instantApply = branch.getBoolPref("preferences.instantApply");
  88.   window.openDialog("chrome://fireftp/content/preferences.xul", "preferences", "chrome,resizable,centerscreen"
  89.                                                                                + (instantApply ? ",dialog=no" : ",modal,dialog"));
  90. }
  91.  
  92. var prefsObserver = {
  93.   observe : function(prefsbranch, topic, data) {
  94.     readPreferences();
  95.  
  96.     if (data == "fireftp.bytesmode") {
  97.       localTree.updateView();
  98.  
  99.       if (gFtp.isConnected) {
  100.         remoteTree.updateView();
  101.       }
  102.     } else if (data == "fireftp.logerrormode") {
  103.       if (gLogErrorMode) {
  104.         showOnlyErrors();
  105.       } else {
  106.         showAll();
  107.       }
  108.     } else if (data == "fireftp.hiddenmode") {
  109.       if (!gFtp.hiddenMode) {
  110.         var file        = localFile.init(gLocalPath.value);
  111.         var hiddenFound = false;
  112.  
  113.         while (true) {
  114.           if (file.isHidden() && file.path != localDirTree.data[0].path) {
  115.             hiddenFound = true;
  116.             break;
  117.           }
  118.  
  119.           if (!(parent in file) || file.path == file.parent.path) {
  120.             break;
  121.           }
  122.  
  123.           file = file.parent;
  124.         }
  125.  
  126.         if (hiddenFound) {
  127.           gLocalPath.value = localDirTree.data[0].path;
  128.         }
  129.       }
  130.  
  131.       localDirTree.data     = new Array();
  132.       localDirTree.treebox.rowCountChanged(0, -localDirTree.rowCount);
  133.       localDirTree.rowCount = 0;
  134.       localDirTree.changeDir(gLocalPath.value);
  135.  
  136.       if (gFtp.isConnected) {
  137.         remoteTree.refresh();
  138.       }
  139.     }
  140.   }
  141. };
  142.